package com.hylanda.sys.dao;

import java.sql.Timestamp;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.hylanda.pb.dao.SqlServerBaseDao;
import com.hylanda.sys.entity.UUser;

/** 
 * @author zhangy
 * @E-mail:blackoon88@gmail.com 
 * @qq:846579287
 * @version created at：2018年2月26日 下午3:36:41 
 * note
 */
@Repository
public class UserRepository extends SqlServerBaseDao{

	public UUser findOne(Long id) {
		return findEntity(UUser.class, id);
	}

	public UUser findByNickname(String username) {
		String sql="select id,email,nickname,pswd from sys_user where email=?";
		Map<String,Object> map=queryForMap(sql, new Object[]{username});
		if(map==null) return null;
		UUser rf=new UUser();
		rf.setId((Long)map.get("id"));
		rf.setEmail((String)map.get("email"));
		rf.setNickname((String)map.get("nickname"));
		rf.setPswd((String)map.get("pswd"));
		rf.setCreateTime((Timestamp)map.get("createTime"));
		return rf;
	}

}
